﻿using System.Collections.Generic;
using System.Linq;
using DataBaseLayer.Dto;

namespace DataBaseLayer.Extensions
{
	public static class DismissalOrderEx
	{
		public static DismissalOrderData ToDto(this DismissalOrder entity)
		{
			if (entity == null) return null;

			var dto = new DismissalOrderData
			{
				AuthorSignature = entity.AuthorSignature,
				Date = entity.Date,
				Id = entity.Id,
				LogOrderId = entity.LogOrderId,
				Number = entity.Number,
				Person = entity.Person,
				Place = entity.Place,
				Profession = entity.Profession,
				StartDate = entity.StartDate,
				StatementAuthor = entity.StatementAuthor,
				PaidDays = entity.PaidDays
			};

			return dto;
		}

		public static IEnumerable<DismissalOrderData> ToDtos(this IEnumerable<DismissalOrder> entities)
		{
			return entities != null ? entities.Select(e => e.ToDto()).ToList() : null;
		}
	}
}
